<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>后台管理首页-超级管理员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="icon" th:href="@{/读书1.jpg}" type="image/jpg" >
    <link rel="stylesheet" href="../static/layui-v2.5.7/layui/css/layui.css" th:href="@{/layui-v2.5.7/layui/css/layui.css}">
    <!--  -->
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="../static/layui-v2.5.7/layui/layui.js" th:src="@{/layui-v2.5.7/layui/layui.js}"></script>
    <!--  -->

</head>

<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">后台管理系统</div>

        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item">
                <i class="layui-icon layui-icon-circle-dot"></i>
                主管理员管理 / 系统首页 / 数据统计
            </li>
        </ul>

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img th:src="${session.adminUser.headImg}" class="layui-nav-img">
                    <span th:text="${session.adminUser.username}"></span>
                </a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/outAdminLogin(id = ${session.adminUser.id})}">
                    <i class="layui-icon layui-icon-logout" style=""></i>
                    退了
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">

                <li class="layui-nav-item layui-this">
                    <a th:href="@{/managementIndex}">
                        <i class="layui-icon layui-icon-home" style=""></i>
                        系统首页
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/userManagement}">
                        <i class="layui-icon layui-icon-user" style=""></i>
                        用户管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/blogManagement}">
                        <i class="layui-icon layui-icon-read" style=""></i>
                        博客管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/postManagement}">
                        <i class="layui-icon layui-icon-file" style=""></i>
                        帖子管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/toCommentManagement}">
                        <i class="layui-icon layui-icon-chat" style=""></i>
                        评论管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/toReplyManagement}">
                        <i class="layui-icon layui-icon-reply-fill" style=""></i>
                        回复管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/userRightsManagement}">
                        <i class="layui-icon layui-icon-util" style=""></i>
                        权限管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/bannerManagement}">
                        <i class="layui-icon layui-icon-carousel" style=""></i>
                        轮播图管理
                    </a>
                </li>

                <li class="layui-nav-item">
                    <a th:href="@{/toSystemMessageManagement}">
                        <i class="layui-icon layui-icon-notice" style=""></i>
                        系统消息
                    </a>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="layui-body_div1" >
            <div class="layui-body_div1_div2">用户统计</div>
            <div class="layui-body_div1_div1" th:text="${userCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

        <div class="layui-body_div1">
            <div class="layui-body_div1_div2">文章统计</div>
            <div class="layui-body_div1_div1" th:text="${blogCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

        <div class="layui-body_div1">
            <div class="layui-body_div1_div2">帖子统计</div>
            <div class="layui-body_div1_div1" th:text="${postCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

        <div class="layui-body_div1">
            <div class="layui-body_div1_div2">评论统计</div>
            <div class="layui-body_div1_div1" th:text="${commentCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

        <div class="layui-body_div1">
            <div class="layui-body_div1_div2">回复统计</div>
            <div class="layui-body_div1_div1" th:text="${replyCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

        <div class="layui-body_div1">
            <div class="layui-body_div1_div2">权限管理人数</div>
            <div class="layui-body_div1_div1" th:text="${userCount}"></div>
            <div class="layui-body_div1_div3">当前总记录数</div>
        </div>

    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        Copyright © 2017-2021  社区SQ.com 版权所有
    </div>
</div>

<script th:inline="javascript">

    layui.use('element', function () {
        var element = layui.element;
    });

    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#test',
            url: '/ImagineCommunity/toBlogManagement',
            cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            method:'POST',
            page:true,
            limit:10,//每页数量，控制每页高度
            height:'full-125',//控制页码高度
            done: function (res, curr, count) {
                //判断本页数据是否为空，空则跳到前一页
                if (curr > 1 && res.data.length === 0) {
                    curr --;
                    //执行重载
                    table.reload('test', {
                        page: {
                            curr: curr //重新从减少一 页开始
                        },
                    });
                }
            },
            cols: [ [
                { field: 'id', width: 70, title: 'ID', sort: true }
                , { field: 'title', width: 150, title: '标题' }
                , { field: 'content', width: 580, title: '内容' }
                , { field: 'value', width: 100, title: '类型' }
                , { field: 'filePath', width: 90, title:'首图',templet:'<div><img  src="{{ d.filePath}}"></div>'}
                , { field: 'userName', width: 100, title: '博主' }
                , { field: 'score', title: '操作', toolbar: '#barDemo',width: '13%' }
            ] ]
        });

        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {  //删除blog信息
                layer.confirm('确定要删除blog【' + obj.data.title + '】么', function (index) {
                    var id = obj.data.id;
                    $.ajax({
                        url:'/ImagineCommunity/deleteAdminBlog',
                        data:{id:id},
                        type:'post',
                        success:function (res) {
                            layer.msg("删除成功!");
                            setTimeout(function() {
                                table.reload("test");
                            }, 1000);
                        }
                    })
                });
            } else if (obj.event === 'detail') { //查看用户信息
                $('.div1_div1_name').html(obj.data.title);
                $('.div1_div1_email').html(obj.data.userName);
                $('.div1_div1_headImg').attr('src',obj.data.filePath);
                $('.div1_div1_statusSpan').html(obj.data.value);
                layui.use('layer', function () {
                    layer.open({
                       type: 1,//1是当前页面内容，2是路径内容
                       area: ["400px", "350px"],
                       content: $("#userDetail").html(), //当前$("#popSearchRoleTest").html()，其他页面test2.html
                       title: "博客信息",
                    })
                })
            }
        });
    });

    <!-- 浏览器关闭事件,浏览器关闭时向后台发送退出链接,thymeleaf内联对象后加个'?',不然不存在时会报错-->
    $(window).unload(function(){
            $.ajax({
                url : "/ImagineCommunity/outAdminLogin?id=[[${session.adminUser.id}]]",
            })
    });

</script>

</body>

<style type="text/css">

    .layui-table-cell{
        text-align:center;
        white-space: normal;
        height:auto;
    }

    .layui-table img{
        max-width:55px;
    }

</style>

<style th:inline="text">

    .layui-body_div1{
        float:left;
        width:30%;
        height:45%;
        //border:1px solid red;
        display:inline-block;
        margin:20px 0px 0px 30px;
        background: rgb(246,246,246);
        background-size: 100% 100%;
    }

    .layui-body_div1_div1{
        font-size:100px;
        //border:1px solid red;
        padding-left:15px;
    }

    .layui-body_div1_div2{
        font-size:20px;
        margin-left:10px;
        margin-top:55px;
        //border:1px solid red;
    }

    .layui-body_div1_div3{
        font-size:20px;
        margin-left:10px;
        //border:1px solid red;
    }

</style>

</html>